package ${package_name}.controller;

import com.enbatis.mybatisplugs.base.BaseController;
import com.enbatis.mybatisplugs.commons.sql.Wrapper;
import com.enbatis.mybatisplugs.commons.utils.ResultReturn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import ${package_name}.entity.${table_name};
import ${package_name}.service.${table_name}Service;


import java.util.List;

@RestController
@RequestMapping("v1/${table_name_small}")
public class ${table_name}Controller extends BaseController {

@Autowired
private ${table_name}Service ${small_hump_table_name}Service;


    @PostMapping("/add")
    public ResultReturn<${table_name}> add(@RequestBody ${table_name} ${small_hump_table_name}){
        return  success(${small_hump_table_name}Service.insert(${small_hump_table_name}));
    }


    @DeleteMapping("/delete")
    public ResultReturn<Integer> delete(@RequestParam("id") Long id){
        return success(${small_hump_table_name}Service.deleteById(id));
    }


    @PutMapping("/{id}")
    public  ResultReturn<Integer> update(@PathVariable("id") Long id,@RequestBody ${table_name} ${small_hump_table_name}){
        ${small_hump_table_name}.setId(id);
        return success(${small_hump_table_name}Service.updateById(${small_hump_table_name}));
    }


    @GetMapping("/{id}")
    public ResultReturn<${table_name}> get(@PathVariable("id") Long id) {
        return success(${small_hump_table_name}Service.getById(id));
    }


    @GetMapping("/list")
    public ResultReturn<List<${table_name}>> getList(${table_name} ${small_hump_table_name}){
        return success(${small_hump_table_name}Service.list(new Wrapper<>(${small_hump_table_name})));
    }

}
